#ifndef ALLAGROGR_H_INCLUDED
#define ALLAGROGR_H_INCLUDED

#include <list>

namespace Oribi
{
    class MouseState;
    #define DEFAULT_SCREEN_WIDTH  640
    #define DEFAULT_SCREEN_HEIGHT 480
    class GraphicContext
    {
    public:
        GraphicContext();

        int initialise(ConfContext&);
        void shutDown();

        void beginFrame();
        void addSpriteToBlitQueue(const Sprite&);
        void blitSprites();
        void endFrame();

        SDL_Surface *getDisplaySurface();

        void addSprite(Sprite*);
        bool removeSprite(Sprite*);

        void updateCamera(const MouseState&);
        void moveCamera(SDL_Point);

        bool rectIntersectsFOV(const SDL_Rect&) const;

        SDL_Point getCameraPosition() const;
        SDL_Rect  getCameraRect()     const;

        friend class OribiApp;
    private:
        BlitQueue blitQueue;
        Uint32 frameBeginTime;
        int screenWidth, screenHeight;
        SDL_Window  *window;
        SDL_Surface *display;
        int cameraSpeed;
        SDL_Point cameraPosition;

        std::list<Sprite*> sprites;
    };
}

#endif // ALLAGROGR_H_INCLUDED
